home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / text / faqs / unix-faq.faq.part5 < prev    next >
Encoding:
Internet Message Format  |  1994-05-16  |  10.3 KB

  1. Subject: Unix - Frequently Asked Questions (5/7) [Frequent posting]
  2. Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
  3. From: tmatimar@isgtec.com (Ted Timar)
  4. Date: 14 May 1994 10:18:53 GMT
  5.  
  6. Archive-name: unix-faq/faq/part5
  7. Version: $Id: part5,v 2.5 1994/04/28 19:25:03 tmatimar Exp $
  8.  
  9. These seven articles contain the answers to some Frequently Asked
  10. Questions often seen in comp.unix.questions and comp.unix.shell.
  11. Please don't ask these questions again, they've been answered plenty
  12. of times already - and please don't flame someone just because they may
  13. not have read this particular posting.  Thank you.
  14.  
  15. This collection of documents is Copyright (c) 1994, Ted Timar.
  16. All rights reserved.  Permission to distribute the collection is
  17. hereby granted providing that distribution is electronic, no money
  18. is involved, reasonable attempts are made to use the latest version
  19. and all credits and this copyright notice are maintained.
  20. Other requests for distribution will be considered.
  21.  
  22. All information here has been contributed with good intentions, but
  23. none of it is guaranteed either by the contributors or myself to be
  24. accurate.  The users of this information take all responsibility for
  25. any damage that may occur.
  26.  
  27. Many FAQs, including this one, are available on the archive site
  28. rtfm.mit.edu in the directory pub/usenet/news.answers.
  29. The name under which a FAQ is archived appears in the "Archive-Name:"
  30. line at the top of the article.  This FAQ is archived as
  31. "unix-faq/faq/part[1-7]".
  32.  
  33. These articles are divided approximately as follows:
  34.  
  35.       1.*) General questions.
  36.       2.*) Relatively basic questions, likely to be asked by beginners.
  37.       3.*) Intermediate questions.
  38.       4.*) Advanced questions, likely to be asked by people who thought
  39.        they already knew all of the answers.
  40.       5.*) Questions pertaining to the various shells, and the differences.
  41.       6.*) An overview of Unix variants.
  42.       7.*) An comparison of configuration management systems (RCS, SCCS).
  43.  
  44. This article includes answers to:
  45.  
  46.       5.1)  Can shells be classified into categories?
  47.       5.2)  How do I "include" one shell script from within another
  48.             shell script?
  49.       5.3)  Do all shells have aliases?  Is there something else that
  50.             can be used?
  51.       5.4)  How are shell variables assigned?
  52.       5.5)  How can I tell if I am running an interactive shell?
  53.       5.6)  What "dot" files do the various shells use?
  54.       5.7)  I would like to know more about the differences between the
  55.             various shells.  Is this information available some place?
  56.  
  57. If you're looking for the answer to, say, question 5.5, and want to skip
  58. everything else, you can search ahead for the regular expression "^5.5)".
  59.  
  60. While these are all legitimate questions, they seem to crop up in
  61. comp.unix.questions or comp.unix.shell on an annual basis, usually
  62. followed by plenty of replies (only some of which are correct) and then
  63. a period of griping about how the same questions keep coming up.  You
  64. may also like to read the monthly article "Answers to Frequently Asked
  65. Questions" in the newsgroup "news.announce.newusers", which will tell
  66. you what "UNIX" stands for.
  67.  
  68. With the variety of Unix systems in the world, it's hard to guarantee
  69. that these answers will work everywhere.  Read your local manual pages
  70. before trying anything suggested here.  If you have suggestions or
  71. corrections for any of these answers, please send them to to
  72. tmatimar@isgtec.com.
  73.  
  74. ----------------------------------------------------------------------
  75.  
  76. Subject: Can shells be classified into categories?
  77. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  78. Date: Wed, 7 Oct 92 14:28:18 -0500
  79.  
  80.  
  81. 5.1)  Can shells be classified into categories?
  82.  
  83.       In general there are two main class of shells.  The first class
  84.       are those shells derived from the Bourne shell which includes sh,
  85.       ksh, bash, and zsh.  The second class are those shells derived
  86.       from C shell and include csh and tcsh.  In addition there is rc
  87.       which most people consider to be in a "class by itself" although
  88.       some people might argue that rc belongs in the Bourne shell class.
  89.  
  90.       With the classification above, using care, it is possible to
  91.       write scripts that will work for all the shells from the Bourne
  92.       shell category, and write other scripts that will work for all of
  93.       the shells from the C shell category.
  94.  
  95. ------------------------------
  96.  
  97. Subject: How do I "include" one shell script from within another shell script?
  98. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  99. Date: Wed, 7 Oct 92 14:28:18 -0500
  100.  
  101. 5.2)  How do I "include" one shell script from within another shell script?
  102.  
  103.       All of the shells from the Bourne shell category (including rc)
  104.       use the "." command.  All of the shells from the C shell category
  105.       use "source".
  106.  
  107. ------------------------------
  108.  
  109. Subject: Do all shells have aliases?  Is there something else that can be used?
  110. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  111. Date: Wed, 7 Oct 92 14:28:18 -0500
  112.  
  113. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  114.  
  115.       All of the major shells other than sh have aliases, but they
  116.       don't all work the same way.  For example, some don't accept
  117.       arguments.
  118.       
  119.       Although not strictly equivalent, shell functions (which exist in
  120.       most shells from the Bourne shell category) have almost the same
  121.       functionality of aliases.  Shell functions can do things that
  122.       aliases can't do.  Shell functions did not exist in bourne shells
  123.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  124.       BSD 4.3 and System V shells do support shell functions.
  125.       
  126.       Use unalias to remove aliases and unset to remove functions.
  127.  
  128. ------------------------------
  129.  
  130. Subject: How are shell variables assigned?
  131. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  132. Date: Wed, 7 Oct 92 14:28:18 -0500
  133.  
  134. 5.4)  How are shell variables assigned?
  135.  
  136.       The shells from the C shell category use "set variable=value" for
  137.       variables local to the shell and "setenv variable value" for
  138.       environment variables.  To get rid of variables in these shells
  139.       use unset and unsetenv.  The shells from the Bourne shell
  140.       category use "variable=value" and may require an "export
  141.       VARIABLE_NAME" to place the variable into the environment.  To
  142.       get rid of the variables use unset.
  143.  
  144. ------------------------------
  145.  
  146. Subject: How can I tell if I am running an interactive shell?
  147. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  148. From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  149. Date: Fri, 23 Oct 92 11:59:19 -0600
  150.  
  151. 5.5)  How can I tell if I am running an interactive shell?
  152.  
  153.       In the C shell category, look for the variable $prompt.
  154.  
  155.       In the Bourne shell category, you can look for the variable $PS1,
  156.       however, it is better to check the variable $-.  If $- contains
  157.       an 'i', the shell is interactive.  Test like so:
  158.  
  159.       case $- in
  160.       *i*)    # do things for interactive shell
  161.               ;;
  162.       *)      # do things for non-interactive shell
  163.               ;;
  164.       esac
  165.  
  166. ------------------------------
  167.  
  168. Subject: What "dot" files do the various shells use?
  169. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  170. From: tmb@idiap.ch (Thomas M. Breuel)
  171. Date: Wed, 28 Oct 92 03:30:36 +0100
  172.  
  173. 5.6)  What "dot" files do the various shells use?
  174.  
  175.       Although this may not be a complete listing, this provides the
  176.       majority of information.
  177.  
  178.       csh
  179.       Some versions have system-wide .cshrc and .login files.  Every
  180.       version puts them in different places.
  181.  
  182.       Start-up (in this order):
  183.           .cshrc   - always.
  184.           .login   - login shells.
  185.  
  186.       Upon termination:
  187.               .logout  - login shells.
  188.  
  189.       Others:
  190.           .history - saves the history (based on $savehist).
  191.  
  192.       tcsh
  193.       Start-up (in this order):
  194.           /etc/csh.cshrc - always.
  195.           /etc/csh.login - login shells.
  196.           .tcshrc        - always.
  197.           .cshrc         - if no .tcshrc was present.
  198.           .login         - login shells
  199.  
  200.       Upon termination:
  201.               .logout        - login shells.
  202.  
  203.       Others:
  204.           .history       - saves the history (based on $savehist).
  205.           .cshdirs       - saves the directory stack.
  206.  
  207.       sh
  208.       Start-up (in this order):
  209.           /etc/profile - login shells.
  210.           .profile     - login shells.
  211.  
  212.       Upon termination:
  213.           any command (or script) specified using the command:
  214.          trap "command" 0
  215.  
  216.       ksh
  217.       Start-up (in this order):
  218.           /etc/profile - login shells.
  219.           .profile     - login shells.
  220.           $ENV         - always, if it is set.
  221.  
  222.       Upon termination:
  223.           any command (or script) specified using the command:
  224.          trap "command" 0
  225.  
  226.       bash
  227.       Start-up (in this order):
  228.               /etc/profile  - login shells.
  229.               .bash_profile - login shells.
  230.               .profile      - login if no .bash_profile is present.
  231.               .bashrc       - interactive non-login shells.
  232.               $ENV          - always, if it is set.
  233.  
  234.       Upon termination:
  235.               .bash_logout  - login shells.
  236.  
  237.       Others:
  238.               .inputrc      - Readline initialization.
  239.  
  240.       zsh
  241.       Start-up (in this order):
  242.               .zshenv   - always, unless -f is specified.
  243.               .zprofile - login shells.
  244.               .zshrc    - interactive shells, unless -f is specified.
  245.               .zlogin   - login shells.
  246.  
  247.       Upon termination:
  248.               .zlogout  - login shells.
  249.  
  250.       rc
  251.       Start-up:
  252.               .rcrc - login shells
  253.  
  254. ------------------------------
  255.  
  256. Subject: I would like to know more about the differences ... ?
  257. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  258. Date: Wed, 7 Oct 92 14:28:18 -0500
  259.  
  260. 5.7)  I would like to know more about the differences between the
  261.       various shells.  Is this information available some place?
  262.  
  263.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  264.       rc is available via anon.  ftp in several places:
  265.  
  266.       cs.uwp.edu (131.210.1.4):pub/vi/docs/shell-100.BetaA.Z
  267.       utsun.s.u-tokyo.ac.jp:misc/vi-archive/docs/shell-100.BetaA.Z
  268.  
  269.       This file compares the flags, the programming syntax,
  270.       input/output redirection, and parameters/shell environment
  271.       variables.  It doesn't discuss what dot files are used and the
  272.       inheritance for environment variables and functions.
  273.  
  274. ------------------------------
  275.  
  276. End of unix/faq Digest part 5 of 7
  277. **********************************
  278.  
  279. -- 
  280. Ted Timar - tmatimar@isgtec.com
  281. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  282.  
  283.